<template>
  <file :name="name" :value="value" :is_info="is_info" :size="size" :more="more" :config="config" :img_src_callback="img_src" :select_after_callback="select_after" @update:value="$emit('update:value', $event)" @change="$emit('change', $event)"></file>
</template>

<script>
import {_href} from "@/js/s94_tool.js";
import file from "@/components/auto_import/UnifyParam/file.vue";
import {msg} from "@/js/tool.js";

export default {
  _title_: '微信素材',
  _can_config_: true,
  components: {file},
  name: "wechat_file",
  props: ['name', 'value', 'config', 'is_info', 'more', 'size', 'is_list'],
  emits: ['update:value', 'change'],
  data(){
    return {}
  },
  methods: {
    img_src(v){
      return _href('/admin/file/info?media_id='+encodeURIComponent(v));
    },
    select_after(selected){
      let arr = [];
      for (let i = 0; i < selected.length; i++) {
        let v = selected[i]['media_id'];
        if (!v) {
          msg.error('所选素材未上传至微信，需要先上传');
          return [];
        }
        arr.push(v)
      }
      return arr;
    },
  },
}
</script>

<style scoped>

</style>